/////////////////////////////////////////
// Controller box lid
//
// Author:    Eric Lind
// Revision:  0
// Rev. Date: 2013-08-11
// 
// History:
// 
/////////////////////////////////////////

//Parameters (changable)
res=100;    							//Resulotion of all arcs
b_width=70;							//Box width
b_length=120;						//Box length
b_height=10;							//Box inner heigth
b_thick=3;							//Box material thicknes
b_i_radius=4;						//Inner radies of corners in box
b_o_radius=b_i_radius+b_thick;		//Outer radies of box
lid_overlap=2;						//Height of overlap for lid


//Model, do not edit!
union(){
	difference() {
		union() {
			//Box corners
			translate([b_o_radius,b_o_radius,0]) {cylinder(r=b_o_radius, h=b_height+b_thick-lid_overlap, $fn=res);}
			translate([b_length-b_o_radius,b_o_radius,0]) {cylinder(r=b_o_radius, h=b_height+b_thick-lid_overlap, $fn=res);}
			translate([b_o_radius,b_width-b_o_radius,0]) {cylinder(r=b_o_radius, h=b_height+b_thick-lid_overlap, $fn=res);}
			translate([b_length-b_o_radius,b_width-b_o_radius,0]) {cylinder(r=b_o_radius, h=b_height+b_thick-lid_overlap, $fn=res);}
		
			//Box
			translate([b_o_radius,0,0]) {cube([b_length-(2*b_o_radius),b_width,b_height+b_thick-lid_overlap]);}
			translate([0,b_o_radius,0]){cube([b_length,b_width-(2*b_o_radius),b_height+b_thick-lid_overlap]);}
			}
		//Inside
		translate([b_o_radius,b_o_radius,b_thick]) {cylinder(r=b_o_radius-b_thick, h=b_height+b_thick, $fn=res);}
		translate([b_length-b_o_radius,b_o_radius,b_thick]) {cylinder(r=b_o_radius-b_thick, h=b_height+b_thick, $fn=res);}
		translate([b_o_radius,b_width-b_o_radius,b_thick]) {cylinder(r=b_o_radius-b_thick, h=b_height+b_thick, $fn=res);}
		translate([b_length-b_o_radius,b_width-b_o_radius,b_thick]) {cylinder(r=b_o_radius-b_thick, h=b_height+b_thick, $fn=res);}
		translate([b_o_radius,b_thick,b_thick]) {cube([b_length-(2*b_o_radius),b_width-(2*b_thick),b_height+b_thick]);}
		translate([b_thick,b_o_radius,b_thick]){cube([b_length-(2*b_thick),b_width-(2*b_o_radius),b_height+b_thick]);}

		//lid overlap corners
		translate([b_o_radius,b_o_radius,b_height-lid_overlap]) {cylinder(r=b_o_radius-(b_thick/2), h=b_height+b_thick, $fn=res);}
		translate([b_length-b_o_radius,b_o_radius,b_height-lid_overlap]) {cylinder(r=b_o_radius-(b_thick/2), h=b_height+b_thick, $fn=res);}
		translate([b_o_radius,b_width-b_o_radius,b_height-lid_overlap]) {cylinder(r=b_o_radius-(b_thick/2), h=b_height+b_thick, $fn=res);}
		translate([b_length-b_o_radius,b_width-b_o_radius,b_height-lid_overlap]) {cylinder(r=b_o_radius-(b_thick/2), h=b_height+b_thick, $fn=res);}

		//lid overlap box
		translate([b_o_radius,(b_thick/2),b_height-lid_overlap]) {cube([b_length-(2*(b_o_radius-(b_thick/2)))-b_thick,b_width-b_thick,b_height+b_thick]);}
		translate([(b_thick/2),b_o_radius,b_height-lid_overlap]) {cube([b_length-b_thick,b_width-(2*(b_o_radius-(b_thick/2)))-b_thick,b_height+b_thick]);}
			
		
	}
}